﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CardGenerator
{
    class DataBase
    {
        public BazaBiletovDataSet bazaBiletovData = new BazaBiletovDataSet();
        private BazaBiletovDataSetTableAdapters.DolgnostTableAdapter DolgnostTableAdapter = new BazaBiletovDataSetTableAdapters.DolgnostTableAdapter();
        private BazaBiletovDataSetTableAdapters.DisciplinaTableAdapter DisciplinaTableAdapter = new BazaBiletovDataSetTableAdapters.DisciplinaTableAdapter();
        private BazaBiletovDataSetTableAdapters.PrepodavatelTableAdapter PrepodavatelTableAdapter = new BazaBiletovDataSetTableAdapters.PrepodavatelTableAdapter();
        private BazaBiletovDataSetTableAdapters.BiletTableAdapter BiletTableAdapter = new BazaBiletovDataSetTableAdapters.BiletTableAdapter();
        private BazaBiletovDataSetTableAdapters.TableAdapterManager tableAdapterManager;
       
        
        public DataBase()
        {
            this.BiletTableAdapter.ClearBeforeFill = true;
            this.DisciplinaTableAdapter.ClearBeforeFill = true;
            this.PrepodavatelTableAdapter.ClearBeforeFill = true;
            this.DolgnostTableAdapter.ClearBeforeFill = true;

            this.BiletTableAdapter.Fill(this.bazaBiletovData.Bilet);
            this.PrepodavatelTableAdapter.Fill(this.bazaBiletovData.Prepodavatel);
            this.DolgnostTableAdapter.Fill(this.bazaBiletovData.Dolgnost);
            this.DisciplinaTableAdapter.Fill(this.bazaBiletovData.Disciplina);
            this.tableAdapterManager = new CardGenerator.BazaBiletovDataSetTableAdapters.TableAdapterManager();

            this.tableAdapterManager.BackupDataSetBeforeUpdate = false;
            this.tableAdapterManager.UpdateOrder = CardGenerator.BazaBiletovDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete;
            this.tableAdapterManager.DisciplinaTableAdapter = this.DisciplinaTableAdapter;
            this.tableAdapterManager.BiletTableAdapter = this.BiletTableAdapter;
            this.tableAdapterManager.DolgnostTableAdapter = this.DolgnostTableAdapter;
            this.tableAdapterManager.PrepodavatelTableAdapter = this.PrepodavatelTableAdapter;

        }

        public void UpdateDB()
        {
            this.tableAdapterManager.UpdateAll(this.bazaBiletovData);
        }
    }
}
